#include "stdafx.h"
#include "MciPlayer.h"
CMciPlayer m_cMci;
BOOL m_bPlay;
char * mg_PlayFile;

int StopPlayFile(void)
{
    if( m_bPlay )
    {
        m_cMci.Stop();  
        m_bPlay = false;
    }

    return 0;
}
#include ".\\Volume\\IVolume.h"
#include "Volume\\volumeOutmaster.h"
#include "Volume\\VolumeOutWave.h"

int StartPlayFile(LPCTSTR FileName, INT PercentVol)
{
    int ret = 1;

    if( m_bPlay ) 
    {
		if (m_bPlay) m_cMci.Stop();  
    }
	m_bPlay        = TRUE;
    CVolumeOutMaster  volmaster;
    DWORD val = volmaster.GetMaximalVolume();
    val = val*PercentVol/100;
    volmaster.SetCurrentVolume(val);
    CVolumeOutWave volwave;

    volwave.SetCurrentVolume(val);
	m_cMci.Play(FileName);

    return ret;
}

int RecordFile(LPCTSTR strFileName)
{
    if( m_cMci.m_bRecFlag )
    {
        m_cMci.Stop();  
    }
    m_cMci.m_bRecFlag = TRUE;
    m_cMci.Record(strFileName);
    return 1;
}

int StopRecordFile()
{
    if( m_cMci.m_bRecFlag )
    {
        m_cMci.Stop();  
        m_cMci.m_bRecFlag = FALSE;
    }
    return 1;
}


int InitMciModule(HWND hParent)
{
    m_cMci.SetSafeHand(hParent);
    return 0;
}

